{% extends 'base.html' %}

{% block title %}供应商管理 - 维修管理系统{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h2>供应商管理</h2>
    <a href="{% url 'spare_parts:supplier_add' %}" class="btn btn-primary">
        <i class="bi bi-plus-circle"></i> 添加供应商
    </a>
</div>

<!-- 供应商列表 -->
<div class="card">
    <div class="card-body">
        {% if suppliers %}
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>供应商名称</th>
                        <th>联系人</th>
                        <th>联系电话</th>
                        <th>邮箱</th>
                        <th>地址</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for supplier in suppliers %}
                    <tr>
                        <td>{{ supplier.name }}</td>
                        <td>{{ supplier.contact_person|default:"-" }}</td>
                        <td>{{ supplier.phone|default:"-" }}</td>
                        <td>{{ supplier.email|default:"-" }}</td>
                        <td>{{ supplier.address|truncatewords:5|default:"-" }}</td>
                        <td>
                            <a href="{% url 'spare_parts:supplier_edit' supplier.pk %}" class="btn btn-sm btn-outline-secondary">
                                编辑
                            </a>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% else %}
        <div class="text-center py-5">
            <i class="bi bi-building-gear display-1 text-muted"></i>
            <h5 class="mt-3">暂无供应商</h5>
            <p class="text-muted">点击"添加供应商"开始创建第一个供应商</p>
        </div>
        {% endif %}
    </div>
</div>
{% endblock %}
